# -*- coding: utf-8 -*-
from calc_setting import * 

def run_single(param_str):
    this_bin = os.path.join(THDMC_dir, THDMC_SCAN_PROGRAM)
    #print("in run single: param_str", this_bin, param_str)
    param_list=param_str.split(",") 
    param_list.insert(0,this_bin)
    param_list=[x.strip() for x in param_list]
    #param_str_list = ""
    #for ele in param_list:
    #    param_str_list += str(ele) + "\n"
    #print("in run single: param_list", this_bin, param_list)
    #print("in run single: param_str_list", this_bin, param_str_list)
    #result = subprocess.run([this_bin, param_str_list.encode()], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    #print("in run single: param_list", param_list)
    slp_time=os.getpid() %1000
    time.sleep(slp_time/1000.0)
    result = subprocess.run(param_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    #result = subprocess.run(["echo this", os.getpid()], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    #result = subprocess.run(['/home/yancywww/Software/bin/HiggsRelated/2HDMC-1.8.0_hbmodified/single_point', '9.271e+01', '1.250e+02', '9.987e+02', '1.912e+02', '-1.005e-01', '1.153e+01', '0.000e+00', '0.000e+00', '7.399e+02', '3', '../output/2_hbhs_output.dat'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    return(result)


if __name__ == '__main__':

#	Create_Folder(output_folder,"/")
	Parallel_Running(run_single, param_df, hbhs_output_file, log_file)
